package com.fhz.circle.widget;

import android.animation.ObjectAnimator;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.fhz.circle.R;
import com.fhz.circle.manager.DialogManager;
import com.fhz.circle.utils.AnimUtils;

/**
 * 时间:11/15/21
 *
 * @author msfeng
 * 简述: 进度条
 */
public class LoadingView {

    private DialogView lodingView;
    private ImageView imageView;
    private TextView textView;

    private ObjectAnimator objectAnimator;

    public LoadingView(Context context) {
        lodingView = DialogManager.getInstance().createDialog(context, R.layout.loading_layout);
        imageView = lodingView.findViewById(R.id.loading_image);
        textView = lodingView.findViewById(R.id.loading_title);
        objectAnimator = AnimUtils.rotation(imageView);
    }

    private void setTitle(String title){
        textView.setText(title);
    }

    public void show(){
        DialogManager.getInstance().show(lodingView);
        objectAnimator.start();
    }

    public void hide(){
        DialogManager.getInstance().hide(lodingView);
        objectAnimator.end();
    }
}
